﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace OnlineManagement.Web.userControl
{
    public partial class UCHybridizationRecord : BaseSowUserControl
    {
        protected int _hoggeryId = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                InitPage();
            }
        }
        private void InitPage() {
            if (SowID != Guid.Empty)
            {
                _hoggeryId = HoggeryID;
                hfSowID.Value = SowID.ToString();
                lbBitID.Text = BitID;
                lbPigpenName.Text = PigPenName;
                lbSowType.Text = SowTypeName;
                if (PropagateStateOrder != Order)
                {
                    Response.Redirect("SowOperations.aspx");
                }
                else
                {
                    BindSowID(_hoggeryId);
                }
            }
        }
        private void BindSowID(int hoggerId)
        {
            BLL.Dal.HybridizationRecord bllhr = new BLL.Dal.HybridizationRecord();
            System.Data.DataSet ds = bllhr.GetHybridizationSow(hoggerId);
            if (ds != null && ds.Tables.Count > 0)
            {
                ddlPigType1.DataSource = ds.Tables[1];
                ddlPigType1.DataTextField = "Name";
                ddlPigType1.DataValueField = "ID";
                ddlPigType1.DataBind();
                ListItem item = new ListItem("--选择品种--", "0");
                ddlPigType1.Items.Insert(0, item);

                ddlPigType2.DataSource = ds.Tables[1];
                ddlPigType2.DataTextField = "Name";
                ddlPigType2.DataValueField = "ID";
                ddlPigType2.DataBind();
                ddlPigType2.Items.Insert(0, item);

                ddlPigType3.DataSource = ds.Tables[1];
                ddlPigType3.DataTextField = "Name";
                ddlPigType3.DataValueField = "ID";
                ddlPigType3.DataBind();
                ddlPigType3.Items.Insert(0, item);
            }

        }
    }
}